home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Dev / Oberon / source / amiga / Config.mod < prev    next >
Text File  |  1995-06-29  |  13KB  |  355 lines

  1. (***************************************************************************
  2.  
  3.      $RCSfile: Config.mod $
  4.   Description: Interface to expansion.library
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.8 $
  8.       $Author: fjc $
  9.         $Date: 1995/06/04 23:13:14 $
  10.  
  11.   Includes Release 40.15
  12.  
  13.   (C) Copyright 1985-1993 Commodore-Amiga, Inc.
  14.       All Rights Reserved
  15.  
  16.   Oberon-A interface Copyright © 1994-1995, Frank Copeland.
  17.   This file is part of the Oberon-A Interface.
  18.   See Oberon-A.doc for conditions of use and distribution.
  19.  
  20. ***************************************************************************)
  21.  
  22. <* STANDARD- *>
  23.  
  24. MODULE [2] Config;
  25.  
  26. IMPORT e := Exec, s := Sets;
  27.  
  28. (*
  29. **      $VER: configregs.h 36.13 (15.2.91)
  30. **
  31. **      AutoConfig (tm) hardware register and bit definitions
  32. *)
  33.  
  34.  
  35. (*
  36. ** AutoConfig (tm) boards each contain a 32 byte "ExpansionRom" area that is
  37. ** read by the system software at configuration time.  Configuration of each
  38. ** board starts when the ConfigIn* signal is passed from the previous board
  39. ** (or from the system for the first board).  Each board will present it's
  40. ** ExpansionRom structure at location $00E80000 to be read by the system.
  41. ** This file defines the appearance of the ExpansionRom area.
  42. **
  43. ** Expansion boards are actually organized such that only one nybble per
  44. ** 16 bit word contains valid information.  The low nybbles of each
  45. ** word are combined to fill the structure below. (This table is structured
  46. ** as LOGICAL information.  This means that it never corresponds exactly
  47. ** with a physical implementation.)
  48. **
  49. ** The ExpansionRom space is further split into two regions:  The first 16
  50. ** bytes are read-only.  Except for the ertype field, this area is inverted
  51. ** by the system software when read in.  The second 16 bytes contain the
  52. ** control portion, where all read/write registers are located.
  53. **
  54. ** The system builds one "ConfigDev" structure for each board found.  The
  55. ** list of boards can be examined using the expansion.library/FindConfigDev
  56. ** function.
  57. **
  58. ** A special "hacker" Manufacturer ID number is reserved for test use:
  59. ** 2011 ($7DB).  When inverted this will look like $F824.
  60. *)
  61.  
  62. TYPE
  63.  
  64.   ExpansionRomPtr * = POINTER TO ExpansionRom;
  65.   ExpansionRom * = RECORD
  66.     type *         : SHORTINT; (* Board type, size and flags *)
  67.     product *      : SHORTINT; (* Product number, assigned by manufacturer *)
  68.     flags *        : s.SET8;   (* Flags *)
  69.     reserved03 *   : SHORTINT; (* Must be zero ($ff inverted) *)
  70.     manufacturer * : e.UWORD;  (* Unique ID,ASSIGNED BY COMMODORE-AMIGA! *)
  71.     serialNumber * : e.ULONG;  (* Available for use by manufacturer *)
  72.     initDiagVec *  : e.UWORD;  (* Offset to optional "DiagArea" structure *)
  73.     reserved0c *   : SHORTINT;
  74.     reserved0d *   : SHORTINT;
  75.     reserved0e *   : SHORTINT;
  76.     reserved0f *   : SHORTINT;
  77.   END; (* ExpansionRom *)
  78.  
  79.  
  80. (*
  81. ** Note that use of the ecBaseAddress register is tricky.  The system
  82. ** will actually write twice.  First the low order nybble is written
  83. ** to the ecBaseAddress register+2 (D15-D12).  Then the entire byte is
  84. ** written to ecBaseAddress (D15-D8).  This allows writing of a byte-wide
  85. ** address to nybble size registers.
  86. *)
  87.  
  88. TYPE
  89.  
  90.   ExpansionControlPtr * = POINTER TO ExpansionControl;
  91.   ExpansionControl * = RECORD
  92.     interrupt *   : SHORTINT; (* Optional interrupt control register *)
  93.     z3HighBase *  : SHORTINT; (* Zorro III   : Config address bits 24-31 *)
  94.     baseAddress * : SHORTINT; (* Zorro II/III: Config address bits 16-23 *)
  95.     shutup *      : SHORTINT; (* The system writes here to shut up a board *)
  96.     reserved14 *  : SHORTINT;
  97.     reserved15 *  : SHORTINT;
  98.     reserved16 *  : SHORTINT;
  99.     reserved17 *  : SHORTINT;
  100.     reserved18 *  : SHORTINT;
  101.     reserved19 *  : SHORTINT;
  102.     reserved1a *  : SHORTINT;
  103.     reserved1b *  : SHORTINT;
  104.     reserved1c *  : SHORTINT;
  105.     reserved1d *  : SHORTINT;
  106.     reserved1e *  : SHORTINT;
  107.     reserved1f *  : SHORTINT;
  108.   END; (* ExpansionControl *)
  109.  
  110. (*
  111. ** many of the constants below consist of a triplet of equivalent
  112. ** definitions: xxMASK is a bit mask of those bits that matter.
  113. ** xxBIT is the starting bit number of the field.  xxSIZE is the
  114. ** number of bits that make up the definition.  This method is
  115. ** used when the field is larger than one bit.
  116. **
  117. ** If the field is only one bit wide then the xxBxx and xxFxx convention
  118. ** is used (xxBxx is the bit number, and xxFxx is mask of the bit).
  119. *)
  120.  
  121. CONST
  122.  
  123. (* manifest constants *)
  124.   slotSize *              = 10000H;
  125.   slotMask *              = 0FFFFH;
  126.   slotShift *             = 16;
  127.  
  128. (* these define the free regions of Zorro memory space.
  129. ** THESE MAY WELL CHANGE FOR FUTURE PRODUCTS!
  130. *)
  131.  
  132.   eExpansionBase *         = 00E80000H;      (* Zorro II  config address *)
  133.   eZ3ExpansionBase *       = 0FF000000H;     (* Zorro III config address *)
  134.  
  135.   eExpansionSize *         = 00080000H;      (* Zorro II  I/O type cards *)
  136.   eExpansionSlots *        = 8;
  137.  
  138.   eMemoryBase *            = 00200000H;      (* Zorro II  8MB space *)
  139.   eMemorySize *            = 00800000H;
  140.   eMemorySlots *           = 128;
  141.  
  142.   eZ3ConfigArea *          = 40000000H;      (* Zorro III space *)
  143.   eZ3ConfigAreaEnd *       = 7FFFFFFFH;      (* Zorro III space *)
  144.   eZ3SizeGranularity *     = 00080000H;      (* 512K increments *)
  145.  
  146.  
  147.  
  148. (**** erType definitions (ttldcmmm) ***************************************)
  149.  
  150. CONST
  151.  
  152. (* erType board type bits -- the OS ignores "old style" boards *)
  153.   ertTypeMask *            = -64;     (* Bits 7-6 *)
  154.   ertTypeBit *             = 6;
  155.   ertTypeSize *            = 2;
  156.   ertNewBoard *            = -64;
  157.   ertZorroII *             = ertNewBoard;
  158.   ertZorroIII *            = -128;
  159.  
  160. (* other bits defined in erType *)
  161.   ertbMemList *            = 5;   (* Link RAM into free memory list *)
  162.   ertbDiagValid *          = 4;   (* ROM vector is valid *)
  163.   ertbChainedConfig *      = 3;   (* Next config is part of the same card *)
  164.  
  165.   ertfMemList *            = 20H;
  166.   ertfDiagValid *          = 10H;
  167.   ertfChainedConfig *      = 08H;
  168.  
  169. (* erType field memory size bits *)
  170.   ertMemMask *             = 07H;    (* Bits 2-0 *)
  171.   ertMemBit *              = 0;
  172.   ertMemSize *             = 3;
  173.  
  174.  
  175. (**** erFlags byte -- for those things that didn't fit into the type byte ****)
  176. (**** the hardware stores this byte in inverted form                       ****)
  177.  
  178. CONST
  179.  
  180.   erffMemSpace       * = -128;   (* Wants to be in 8 meg space. *)
  181.   erfbMemSpace       * = 7;      (* (NOT IMPLEMENTED) *)
  182.  
  183.   erffNoShutUp       * = 64;     (* Board can't be shut up *)
  184.   erfbNOShutUP       * = 6;
  185.  
  186.   erffExtended       * = 32;     (* Zorro III: Use extended size table *)
  187.   erfbExtended       * = 5;      (*            for bits 0-2 of er_Type *)
  188.                                  (* Zorro II : Must be 0 *)
  189.  
  190.   erffZorroIII       * = 16;     (* Zorro III: must be 1 *)
  191.   erfbZorroIII       * = 4;      (* Zorro II : must be 0 *)
  192.  
  193.  
  194.   ertZ3SSMask        * = 0FH;    (* Bits 3-0.  Zorro III Sub-Size.  How *)
  195.   ertZ3SSBit         * = 0;      (* much space the card actually uses   *)
  196.   ertZ3SSSize        * = 4;      (* (regardless of config granularity)  *)
  197.                                  (* Zorro II : must be 0        *)
  198.  
  199.  
  200. (* ecInterrupt register (unused) ********************************************)
  201.  
  202. CONST
  203.   ecibINTENA         * = 1;
  204.   ecibRESET          * = 3;
  205.   ecibINT2PEND       * = 4;
  206.   ecibINT6PEND       * = 5;
  207.   ecibINT7PEND       * = 6;
  208.   ecibINTERRUPTING   * = 7;
  209.  
  210.   ecifINTENA         * = 2;
  211.   ecifRESET          * = 8;
  212.   ecifINT2PEND       * = 16;
  213.   ecifINT6PEND       * = 32;
  214.   ecifINT7PEND       * = 64;
  215.   ecifINTERRUPTING   * = -128;
  216.  
  217.  
  218. (***************************************************************************
  219. **
  220. ** these are the specifications for the diagnostic area.  If the Diagnostic
  221. ** Address Valid bit is set in the Board Type byte (the first byte in
  222. ** expansion space) then the Diag Init vector contains a valid offset.
  223. **
  224. ** The Diag Init vector is actually a word offset from the base of the
  225. ** board.  The resulting address points to the base of the DiagArea
  226. ** structure.  The structure may be physically implemented either four,
  227. ** eight, or sixteen bits wide.  The code will be copied out into
  228. ** ram first before being called.
  229. **
  230. ** The daSize field, and both code offsets (daDiagPoint and daBootPoint)
  231. ** are offsets from the diag area AFTER it has been copied into ram, and
  232. ** "de-nibbleized" (if needed).  (In other words, the size is the size of
  233. ** the actual information, not how much address space is required to
  234. ** store it.)
  235. **
  236. ** All bits are encoded with uninverted logic (e.g. 5 volts on the bus
  237. ** is a logic one).
  238. **
  239. ** If your board is to make use of the boot facility then it must leave
  240. ** its config area available even after it has been configured.  Your
  241. ** boot vector will be called AFTER your board's final address has been
  242. ** set.
  243. **
  244. ****************************************************************************)
  245.  
  246. TYPE
  247.  
  248.   DiagAreaPtr * = POINTER TO DiagArea;
  249.   DiagArea * = RECORD
  250.     config *     : e.UBYTE; (* see below for definitions *)
  251.     flags *      : s.SET8;  (* see below for definitions *)
  252.     size *       : e.UWORD; (* the size (in bytes) of the total diag area *)
  253.     diagPoint *  : e.UWORD; (* where to start for diagnostics, or zero *)
  254.     bootPoint *  : e.UWORD; (* where to start for booting *)
  255.     name *       : e.UWORD; (* offset in diag area where a string *)
  256.                             (*   identifier can be found (or zero if no *)
  257.                             (*   identifier is present). *)
  258.  
  259.     reserved01 * : e.UWORD; (* two words of reserved data.  must be zero. *)
  260.     reserved02 * : e.UWORD;
  261.   END; (* DiagArea *)
  262.  
  263. (* daConfig definitions *)
  264. (*
  265. ** dacByteWide can be simulated using dacNibbleWide.
  266. *)
  267.  
  268. CONST
  269.  
  270.   dacBusWidth *    = 0C0X; (* two bits for bus width *)
  271.   dacNibbleWide *  = 00X;
  272.   dacByteWide *    = 40X; (* BUG: Will not work under V34 Kickstart! *)
  273.   dacWordWide *    = 80X;
  274.  
  275.   dacBootTime *    = 30X;    (* two bits for when to boot *)
  276.   dacNever *       = 00X;    (* obvious *)
  277.   dacConfigTime *  = 10X;    (* call daBootPoint when first configing *)
  278.                                 (*   the device *)
  279.   dacBindTime *    = 20X;    (* run when binding drivers to boards *)
  280.  
  281. (*
  282. **
  283. ** These are the calling conventions for the diagnostic callback
  284. ** (from daDiagPoint):
  285. **
  286. ** A7 -- points to at least 2K of stack
  287. ** A6 -- ExecBase
  288. ** A5 -- ExpansionBase
  289. ** A3 -- your board's ConfigDev structure
  290. ** A2 -- Base of diag/init area that was copied
  291. ** A0 -- Base of your board
  292. **
  293. ** Your board must return a value in D0.  If this value is NULL, then
  294. ** the diag/init area that was copied in will be returned to the free
  295. ** memory pool.
  296. *)
  297.  
  298.  
  299. (*
  300. **      $VER: configvars.h 36.14 (22.4.91)
  301. **
  302. **      Software structures used by AutoConfig (tm) boards
  303. *)
  304.  
  305.  
  306. (*
  307. ** At early system startup time, one ConfigDev structure is created for
  308. ** each board found in the system.  Software may seach for ConfigDev
  309. ** structures by vendor & product ID number.  For debugging and diagnostic
  310. ** use, the entire list can be accessed.  See the expansion.library document
  311. ** for more information.
  312. *)
  313.  
  314. TYPE
  315.  
  316.   ConfigDevPtr * = POINTER TO ConfigDev;
  317.   ConfigDev * = RECORD (e.NodeBase)
  318.     node *      : e.Node;
  319.     flags *     : s.SET8;             (* (read/write) *)
  320.     pad         : e.UBYTE;            (* reserved *)
  321.     rom *       : ExpansionRom;       (* copy of board's expansion ROM *)
  322.     boardAddr * : e.APTR;             (* where in memory the board was placed *)
  323.     boardSize * : e.ULONG;            (* size of board in bytes *)
  324.     slotAddr    : e.UWORD;            (* which slot number (PRIVATE) *)
  325.     slotSize    : e.UWORD;            (* number of slots (PRIVATE) *)
  326.     driver *    : e.APTR;             (* pointer to node of driver *)
  327.     nextCD *    : ConfigDevPtr;       (* linked list of drivers to config *)
  328.     unused      : ARRAY 4 OF e.ULONG; (* for whatever the driver wants *)
  329.   END; (* ConfigDev *)
  330.  
  331. CONST
  332.  
  333. (* cdFlags *)
  334.   cdShutup *      = 0;       (* this board has been shut up *)
  335.   cdConfigMe *    = 1;       (* this board needs a driver to claim it *)
  336.   cdBadMemory *   = 2;       (* this board contains bad memory *)
  337.  
  338.  
  339. (*
  340. ** Boards are usually "bound" to software drivers.
  341. ** This structure is used by GetCurrentBinding() and SetCurrentBinding()
  342. *)
  343.  
  344. TYPE
  345.  
  346.   CurrentBindingPtr * = POINTER TO CurrentBinding;
  347.   CurrentBinding * = RECORD
  348.     configDev *     : ConfigDevPtr; (* first configdev in chain *)
  349.     fileName *      : e.LSTRPTR;    (* file name of driver *)
  350.     productString * : e.LSTRPTR;    (* product # string *)
  351.     toolTypes *     : e.APTR;       (* tooltypes from disk object *)
  352.   END; (* CurrentBinding *)
  353.  
  354. END Config.
  355.